﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;
using Entity;

namespace DataControls
{

   public class LOAIDETAI_Data
    {
        DETAI detai = new DETAI();
        DataBaseAccess dataBaseAccess = new DataBaseAccess();


        public void loaidetai_Combobox(ComboBox cbDeTai)
        {
            String excuteString = "SELECT * FROM LOAIDETAI";
            dataBaseAccess.loadlen_Combobox(cbDeTai, excuteString);
        }

        public Boolean kiemtraLoaiDT_DeTai(String loaidetai)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM DETAI WHERE LOAIDT='" + loaidetai + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else
                return false;
        }

        public Boolean kiemtra_LoaiDeTai(String loaidetai)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM LOAIDETAI WHERE LOAIDT='" + loaidetai + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else 
                return false;
        }

        public int tinchi_DeTai(String loaidetai)
        {
            int a = 0;
            a = Convert.ToInt16(dataBaseAccess.excuteScalar("SELECT SOTC FROM LOAIDETAI WHERE LOAIDT='" + loaidetai + "'"));
            return a;
        }
/*
        public Boolean kiemtra_TenLoaiDeTai(String tenloaidetai)
        {
            int  i = 0;
            String excuteString = "SELECT * FROM LOAIDETAI WHERE TEN LDT='" + tenloaidetai + "'";
            i= dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else
                return false;
        }
 **/
    }
}
